/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package function;

import engine.goods.Goods;
import engine.skill.SkillBuffManager;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import mainpackage.Constant;
import mainpackage.GameBean;
import mainpackage.InputInterFace;
import mainpackage.MainCanvas;
import mainpackage.MainGame;
import mainpackage.MainLogic;
import mainpackage.MainView;
import mainpackage.ResManager;
import mainpackage.Tools;

/**
 *
 * @author Administrator
 */
public class GameSet {

    private static int iUiState = 1;
    private int iUiWidth = 0;
    private int iUiHeight = 0;
    private int iPositionX = 0; //记录跑马灯位置
    private int iPositionY = 0; // 记录选择线的位置
    private int skillindex;
//    private int iSMenuIndex;
//    private int sCurrentPage, sTotalPage;
    private static int sCurrentPage_2, sTotalPage_2;
    private byte byPopUpState = -1; //记录界面弹出层的UI状态变化
    private String sMarqueeString;
    private String[] strNote;
    private Image[] imgArray;
    public static int skillQuickSetindex;
    private boolean bFlag;
    private int iCount;
    public static Goods QuickSetitems;//快捷键上的物品
    /*
     * 初始化快捷栏
     */

    public GameSet() {
//        this.initQuickSet();
    }

    public void initQuickSet() {
        QuickSetitems = new Goods((short) 9, Constant.ITEM_COLUMN_TYPE_COMMON);
        skillindex = 0;
//        iUiWidth = 160;
//        iUiHeight = 200;
        strNote = new String[]{"快捷键", "快捷键设置", "设置心法技能", "设置道具", "设置功能", "1 战斗快捷键设置", "2 非战斗快捷键设置"};
        QuickSet_operationTyte = 0;
//        #if NOKIA_S60V5
//        try {
//            this.imgArray = new Image[8];
//            this.imgArray[0] = ResManager.createImage(90000041); //小箭头图片
//            this.imgArray[1] = Tools.makeBlueMask(); //蓝色选择条
//            this.imgArray[2] = ResManager.createImage(90000017);//背景图片
//            this.imgArray[3] = Tools.makeTransparent(ResManager.createImage(90000051), 255); //边框图片
//            this.imgArray[4] = ResManager.createImage(90000086);//蓝条
//            this.imgArray[5] = ResManager.createImage(90000043);  //文字图片
//            this.imgArray[6] = ResManager.createImage(90000085);//确认按钮图片
//            this.imgArray[7] = ResManager.createImage(90000084);//方向键图片
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        #else
        //#if NOKIA_S60V5
         imgArray = new Image[17];
        //#else
//#        imgArray = new Image[11];
        //#endif
        try {
            //箭头图片
            this.imgArray[0] = ResManager.createImage(90000041, Constant.RES_PUBLIC_TEMP, Constant.RES_UI_PATH, false, -1);
            //蓝色光片
            this.imgArray[1] = Tools.createPicFromGrayscale(ResManager.createImage(90000029), 0x0099ff);
            //背景图片
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[2] = ResManager.createImage(90000017);
//# //            imgArray[2] = Tools.ZoomImage(imgArray[2], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
            //背景图片
            this.imgArray[2] = ResManager.createImage(90000017, Constant.RES_PUBLIC_TEMP, Constant.RES_UI_PATH, false, -1);
            //#endif
            //格子背景图片
            this.imgArray[3] = Goods.createGoodsBg((byte) 1);
            //装备的图标
//            this.imgArray[4] = Tools.makeTransparent(ResManager.createImage(90000064, Constant.RES_PUBLIC_TEMP, Constant.RES_UI_PATH, false, -1), 255);
            //文字图片
            this.imgArray[5] = ResManager.createImage(90000060, Constant.RES_PUBLIC_TEMP, Constant.RES_UI_PATH, false, -1);
            //ResManager.createImage(90000060);
            //背景遮罩图
            this.imgArray[6] = Tools.makeTransparent(Constant.SCREEN_WIDTH, Constant.SCREEN_HEIGHT / 2, 120, 0x00000000);
            this.imgArray[7] = Tools.makeTransparent(ResManager.createImage(90000062), 255);
            this.imgArray[8] = Tools.makeTransparent(ResManager.createImage(90000051), 220);
            //圆角图片tishi.png
            this.imgArray[9] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
            this.imgArray[10] = Tools.makeTransparent(218, 20, 220, 0x989898);
            ///
            //#if NOKIA_S60V5
             this.imgArray[11] = ResManager.createImage(90000086);//蓝条
             this.imgArray[12] = ResManager.createImage(90000043);  //文字图片
             this.imgArray[13] = ResManager.createImage(90000085);//确认按钮图片
             this.imgArray[14] = ResManager.createImage(90000084);//方向键图片
             this.imgArray[15] = Tools.makeTransparent(24, 24, 127, 0x87888D);//快捷键背景
             this.imgArray[16] = Tools.makeTransparent(ResManager.createImage(90000087), -1);//头像（小地图、快捷栏）边框
            //#else
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }
//        #endif
    }
    /*
     * 更新快捷键设置
     */

    public void updateQuickSet() {
        if (GameBean.b_WAIT_NET_MSG_BACK) {
            return;
        }
        iCount++;
        if (iCount > 3) {
            this.bFlag = bFlag ? false : true;
            iCount = 0;
        }
        switch (QuickSet_operationTyte) {
            case QuickSet_interface:
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                    skillQuickSetindex = skillQuickSetindex < 8 ? (skillQuickSetindex + 1) : 0;
                }
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                    skillQuickSetindex = skillQuickSetindex > 0 ? (skillQuickSetindex - 1) : 8;
                }
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {//返回
                    if (GameBean.BY_PRE_GAME_UI_STATE == Constant.GAME_UI_SKILL) {
                        MainLogic.getInstance().send(Constant.MSG_NET_OPEN_KUNGFU, Constant.SOCKET_MSG_TYPE_LOGIC);
                    } else {
                        //跳转到漫游界面
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_SET_QUICK, Constant.SOCKET_MSG_TYPE_LOGIC);
                        Tools.openRoamMenu(false, (byte) 1, (byte) 9, 1);
                        GameBean.BY_PRE_GAME_UI_STATE = -1;
                    }
                }
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)
                        || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {//确定
                    if (GameBean.BY_PRE_GAME_UI_STATE == Constant.GAME_UI_SKILL) {
                        getQuickSet(getSettype, getSeticon, getSetid, getSetname, getSetdescription, getSetnum);
                        GameBean.BY_PRE_GAME_UI_STATE = -1;
                        getSettype = null;
                        getSeticon = null;
                        getSetid = null;
                        getSetname = null;
                        getSetdescription = null;
                        getSetnum = null;
                    } else {
                        QuickSet_operationTyte = QuickSet_operation;
                        skillindex = 0;
                        if (QuickSet[skillQuickSetindex][0] != null) {
                            if (QuickSet[skillQuickSetindex][1].equals("3")) {
                                QuickSet_operationStr = new String[]{"技能", "物品", "功能", "清除"};
                            } else {
                                QuickSet_operationStr = new String[]{"技能", "物品", "功能", "清除", "查看"};
                            }
//                            QuickSet_operationStr = new String[]{"技能", "物品",  "查看", "清除"};
                        } else {
                            QuickSet_operationStr = new String[]{"技能", "物品", "功能"};
//                            QuickSet_operationStr = new String[]{"技能", "物品"};
                        }
                    }
                }
                break;
            case QuickSet_operation:
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                    skillindex = skillindex < (QuickSet_operationStr.length - 1) ? (skillindex + 1) : 0;
                }
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                    skillindex = skillindex > 0 ? (skillindex - 1) : (QuickSet_operationStr.length - 1);
                }
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {//返回
                    QuickSet_operationTyte = QuickSet_interface;
                }

                if (skillindex == 0) {
                    if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)
                            || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {//确定
                        GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_GAMESET_QUICKEYS;
                        MainLogic.getInstance().send(Constant.MSG_NET_OPEN_KUNGFU, Constant.SOCKET_MSG_TYPE_LOGIC);
                    }
                }
                if (skillindex == 1) {
                    if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)
                            || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {//确定
                        GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_GAMESET_QUICKEYS;
                        MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_COMMON);
                    }
                }
                if (skillindex == 2) {
                    if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)
                            || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {//确定
                        GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_GAMESET_QUICKEYS;
                        MainLogic.getInstance().pushState(Constant.GAME_UI_FUNC_SETTING, true);
                    }
                }
                if (skillindex == 3) {
                    if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)
                            || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {//确定
                        for (int i = 0; i < 7; i++) {
                            QuickSet[skillQuickSetindex][i] = null;
                            imgArrayQuickSetIcon[skillQuickSetindex] = null;
                        }
                        Tools.printLog("清除：：：：：：：：：：：：：：：：：");
                        QuickSet_operationTyte = QuickSet_interface;
                    }
                }
                if (skillindex == 4) {
                    if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)
                            || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {//确定
                        if (QuickSet[skillQuickSetindex][1].equals("1")) {
                            GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_GAMESET_QUICKEYS;
                            getsetSkillKey = QuickSet[skillQuickSetindex][3];
                            Tools.printLog("getsetSkillKey   :::::::  " + getsetSkillKey);
                            MainLogic.getInstance().send(Constant.MSG_NET_CHECK_SKILL, Constant.SOCKET_MSG_TYPE_LOGIC);
                            QuickSet_operationTyte = QuickSet_view;
                        } else if (QuickSet[skillQuickSetindex][1].equals("2")) {//这里是查看物品
                            MainLogic.getInstance().uiInterFace.sysMessage.checkItem(QuickSet[skillQuickSetindex][4], (byte) -1, imgArrayQuickSetIcon[skillQuickSetindex], MainLogic.getInstance().gamePlayer.lPlayerID, Long.parseLong(QuickSet[skillQuickSetindex][3]));
                            QuickSet_operationTyte = QuickSet_operation;
                        }
                    }
                }
                break;
            case QuickSet_view:
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {//返回
                    QuickSet_operationTyte = QuickSet_operation;
                }
                break;
            case QuickSet_delete:
                break;
        }
    }
    /*
     * 绘制快捷键设置
     */
    public static Image[] imgArrayQuickSetIcon = new Image[9];
    //获得职业技能图标
    public static String getsetSkillKey;
    private String[] getsetskillDescription;
    private int getsetskillDescription_Height;

    public void getskillDescription(String skill_name, byte now_level, byte highest_level,
            byte skill_type, int sp_num, int cd_num, String skill_Description) {
        getsetskillDescription = new String[7];
        getsetskillDescription[0] = skill_name;
        getsetskillDescription[1] = "" + now_level;
        getsetskillDescription[2] = "" + highest_level;
        getsetskillDescription[3] = "" + skill_type;
        getsetskillDescription[4] = "" + sp_num;
        getsetskillDescription[5] = "" + cd_num;
        getsetskillDescription[6] = skill_Description;
        getsetskillDescription_Height = Tools.getParagraphHeight(skill_Description, Constant.SCREEN_WIDTH - 18,
                Constant.FONT_SMALL.getHeight());
    }

    public static void getQuickSetIcon(int iconindex, String icon) {
        Tools.printLog("icon   :::  " + icon);
        if (icon == null) {
            imgArrayQuickSetIcon[iconindex] = null;
        } else {
            try {
                imgArrayQuickSetIcon[iconindex] = ResManager.createImage(Integer.parseInt(icon));
                //设置漫游界面快捷键
//            imgArrayQuickSetIcon[iconindex] = Tools.ZoomImage(imgArrayQuickSetIcon[iconindex], 29, 29);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    public static String getSettype, getSeticon, getSetid, getSetname, getSetdescription, getSetnum;
    public static String[][] QuickSet = new String[9][7];//0位置;1快捷中是什么类型的1代表技能2代表物品3代表功能；2图标；3ID；4名字；5描述，6数量
    public long[][] quickSetTime = new long[9][2];//0：物品使用时的时间；1：物品使用间隔时间

    public static void getQuickSet(String type, String icon, String id, String name, String Description, String num) {
        QuickSet[skillQuickSetindex][0] = "" + skillQuickSetindex;
        QuickSet[skillQuickSetindex][1] = type;
        QuickSet[skillQuickSetindex][2] = icon;
        QuickSet[skillQuickSetindex][3] = id;
        QuickSet[skillQuickSetindex][4] = name;
        QuickSet[skillQuickSetindex][5] = Description;
        QuickSet[skillQuickSetindex][6] = num;
//        for (int i = 0; i < 6; i++) {
//            Tools.printLog("ff :::  " + QuickSet[skillSelectindex][i]);
//        }
        getQuickSetIcon(skillQuickSetindex, QuickSet[skillQuickSetindex][2]);
        MainLogic.getInstance().pushState(Constant.GAME_UI_GAMESET_QUICKEYS, true);
//        GameBean.BY_PRE_GAME_UI_STATE = -1;
        iUiState = 1;
    }
    private static byte QuickSet_operationTyte;
    private final byte QuickSet_interface = 0;
    private final byte QuickSet_operation = 1;
    private final byte QuickSet_view = 2;
    private final byte QuickSet_delete = 3;
    private String[] QuickSet_operationStr;

    public void drawQuickSet(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[2], this.imgArray[14],
                 this.imgArray[13], this.imgArray[11], this.imgArray[12], "快捷键");
         int start_Y = (Constant.NEW_END_LINE - this.imgArray[1].getHeight() * 2) / 2;
 
        //#else
//#        Tools.drawFrame(g,
//#                Constant.UI_START_X, Constant.UI_START_Y,
//#                this.imgArray[2], this.imgArray[0],
//#                this.imgArray[1],
//#                this.imgArray[5],
//#                0, 0, 24, 12,
//#                this.imgArray[5], 48, 0, 24, 12,
//#                "快捷键", 0xFFFFFF);
//#        int start_Y = (Constant.SCREEN_HEIGHT - this.imgArray[1].getHeight() * 2) / 2;
        //#endif
        Tools.drawShadowString(g, (byte) 1, strNote[1], Constant.UI_START_X
                + ((Constant.SCREEN_WIDTH - Constant.FONT_SMALL.stringWidth(strNote[1])) >> 1),
                start_Y - Constant.FONT_SMALL_HEIGHT - 5, 0x00E7FF, 0x333333);
        //箭头
        //#if NOKIA_S60V5
         int X = ((Constant.SCREEN_WIDTH - Constant.FONT_SMALL.stringWidth(strNote[1])) >> 1);
         if (bFlag) {
             Tools.drawArrow(g, this.imgArray[0], (byte) 2,
                     Constant.UI_START_X + Constant.SCREEN_WIDTH - X + 5,
                     start_Y - Constant.FONT_SMALL_HEIGHT - 5 + 10);
             Tools.drawArrow(g, this.imgArray[0], (byte) 1,
                     Constant.UI_START_X + X - 10,
                     start_Y - Constant.FONT_SMALL_HEIGHT - 5 + 10);
         } else {
             Tools.drawArrow(g, this.imgArray[0], (byte) 2,
                     Constant.UI_START_X + Constant.SCREEN_WIDTH - X + 7,
                     start_Y - Constant.FONT_SMALL_HEIGHT - 5 + 10);
             Tools.drawArrow(g, this.imgArray[0], (byte) 1,
                     Constant.UI_START_X + X - 12,
                     start_Y - Constant.FONT_SMALL_HEIGHT - 5 + 10);
         }
        //#else
//#        int X = ((Constant.SCREEN_WIDTH - Constant.FONT_SMALL.stringWidth(strNote[1])) >> 1);
//#        if (bFlag) {
//#            Tools.drawArrow(g, this.imgArray[0], (byte) 2,
//#                    Constant.UI_START_X + Constant.SCREEN_WIDTH - X + 5,
//#                    start_Y - Constant.FONT_SMALL_HEIGHT - 5 + 7);
//#            Tools.drawArrow(g, this.imgArray[0], (byte) 1,
//#                    Constant.UI_START_X + X - 10,
//#                    start_Y - Constant.FONT_SMALL_HEIGHT - 5 + 7);
//#        } else {
//#            Tools.drawArrow(g, this.imgArray[0], (byte) 2,
//#                    Constant.UI_START_X + Constant.SCREEN_WIDTH - X + 7,
//#                    start_Y - Constant.FONT_SMALL_HEIGHT - 5 + 7);
//#            Tools.drawArrow(g, this.imgArray[0], (byte) 1,
//#                    Constant.UI_START_X + X - 12,
//#                    start_Y - Constant.FONT_SMALL_HEIGHT - 5 + 7);
//#        }
        //#endif
        //画蓝色的背景
        Tools.drawTilePic(g, (byte) 1, Constant.UI_START_X, start_Y - this.imgArray[1].getHeight(), Constant.SCREEN_WIDTH, this.imgArray[1],
                0, 0, this.imgArray[1].getWidth(), this.imgArray[1].getHeight(), Constant.TRANS_NONE);
        Tools.drawTilePic(g, (byte) 1, Constant.UI_START_X, start_Y + this.imgArray[1].getHeight() * 2,
                Constant.SCREEN_WIDTH, this.imgArray[1],
                0, 0, this.imgArray[1].getWidth(), this.imgArray[1].getHeight(), Constant.TRANS_ROT180);
        g.setColor(0x000000);
        g.drawLine(Constant.UI_START_X, start_Y, Constant.SCREEN_WIDTH, start_Y);
        g.setColor(0x000000);
        g.drawLine(Constant.UI_START_X, start_Y + this.imgArray[1].getHeight() * 2,
                Constant.UI_START_X + Constant.SCREEN_WIDTH, start_Y + this.imgArray[1].getHeight() * 2);
        //画格子
        for (int i = 0; i < 9; i++) {
            //#if NOKIA_S60V5
             MainLogic.getInstance().uiInterFace.drawQuickSetRect(g, this.imgArray[16], this.imgArray[15],
                     (Constant.SCREEN_WIDTH - (38 * 9)) / 2 + 38 * i,
                     start_Y + (this.imgArray[1].getHeight() * 2 - 38) / 2);
 
            //#else
//#            Tools.drawPackageBox(g, this.imgArray[3],
//#                    (Constant.SCREEN_WIDTH - (25 * 9)) / 2 + 25 * i,
//#                    start_Y + (this.imgArray[1].getHeight() * 2 - 25) / 2,
//#                    (byte) 0, 13, 13);
//#
            //#endif
        }
        //画得到的技能
        for (int i = 0; i < 9; i++) {
            if (QuickSet[i][0] != null && imgArrayQuickSetIcon[i] != null) {
                //#if NOKIA_S60V5
                 g.drawImage(imgArrayQuickSetIcon[i], (Constant.SCREEN_WIDTH - 38 * 9) / 2
                         + 38 * i + 5,
                         start_Y + (this.imgArray[1].getHeight() * 2 - 38) / 2 + 5, 0);
                 if (QuickSet[i][1].equals("2")) {
                     Tools.drawNumPic(g, this.imgArray[7], QuickSet[i][6], (byte) 2,
                             (Constant.SCREEN_WIDTH - 38 * 9) / 2
                             + 38 * i,
                             start_Y + (this.imgArray[1].getHeight() * 2 - 38) / 2, (byte) 1);
                 }
                //#else
//#                g.drawImage(imgArrayQuickSetIcon[i], (Constant.SCREEN_WIDTH - 25 * 9) / 2
//#                        + 25 * i - 2,
//#                        start_Y + (this.imgArray[1].getHeight() * 2 - 25) / 2 - 2, 0);
//#                if (QuickSet[i][1].equals("2")) {
//#                    Tools.drawNumPic(g, this.imgArray[7], QuickSet[i][6], (byte) 2,
//#                            (Constant.SCREEN_WIDTH - 25 * 9) / 2
//#                            + 25 * i,
//#                            start_Y + (this.imgArray[1].getHeight() * 2 - 25) / 2, (byte) 1);
//#                }
                //#endif
            }
            //#if NOKIA_S60V5
             Tools.drawNumPic(g, this.imgArray[7], String.valueOf((i + 1)), (byte) 1,
                     (Constant.SCREEN_WIDTH - (38 * 9)) / 2 + 38 * i + 15,
                     start_Y + (this.imgArray[1].getHeight() * 2 - 38) / 2 + 30, (byte) 1);
            //#else
//#            Tools.drawNumPic(g, this.imgArray[7], String.valueOf((i + 1)), (byte) 1,
//#                    (Constant.SCREEN_WIDTH - (25 * 9)) / 2 + 25 * i + 10,
//#                    start_Y + (this.imgArray[1].getHeight() * 2 - 25) / 2 + 22, (byte) 1);
            //#endif
        }
        //格子遮罩
        //#if NOKIA_S60V5
         Tools.drawTilePic(g, (byte) 1, (Constant.SCREEN_WIDTH - 38 * 9) / 2
                 + 38 * skillQuickSetindex,
                 start_Y + (this.imgArray[1].getHeight() * 2 - 38) / 2,
                 38, this.imgArray[1],
                 0, this.imgArray[1].getHeight() - 19,
                 this.imgArray[1].getWidth(), 19, Constant.TRANS_ROT180);
         Tools.drawTilePic(g, (byte) 1, (Constant.SCREEN_WIDTH - 38 * 9) / 2
                 + 38 * skillQuickSetindex,
                 start_Y + (this.imgArray[1].getHeight() * 2 - 38) / 2 + 19,
                 38, this.imgArray[1],
                 0, this.imgArray[1].getHeight() - 19,
                 this.imgArray[1].getWidth(), 19, Constant.TRANS_NONE);
        //#else
//#        Tools.drawTilePic(g, (byte) 1, (Constant.SCREEN_WIDTH - 25 * 9) / 2
//#                + 25 * skillQuickSetindex,
//#                start_Y + (this.imgArray[1].getHeight() * 2 - 25) / 2,
//#                26, this.imgArray[1],
//#                0, this.imgArray[1].getHeight() - 13,
//#                this.imgArray[1].getWidth(), 13, Constant.TRANS_ROT180);
//#        Tools.drawTilePic(g, (byte) 1, (Constant.SCREEN_WIDTH - 25 * 9) / 2
//#                + 25 * skillQuickSetindex,
//#                start_Y + (this.imgArray[1].getHeight() * 2 - 25) / 2 + 13,
//#                26, this.imgArray[1],
//#                0, this.imgArray[1].getHeight() - 13,
//#                this.imgArray[1].getWidth(), 13, Constant.TRANS_NONE);
        //#endif
        //说明文字
        if (QuickSet_operationTyte != QuickSet_view) {
            if (QuickSet[skillQuickSetindex][0] != null) {
                String skillname = QuickSet[skillQuickSetindex][4];
                int skillN_y = start_Y + this.imgArray[1].getHeight() * 2;
                Tools.drawShadowString(g, (byte) 1, skillname, Constant.UI_START_X + (Constant.SCREEN_WIDTH - Constant.FONT_SMALL.stringWidth(skillname)) / 2,
                        Constant.UI_START_Y + skillN_y + 5, 0xFFFF00, 0x333333);
                skillname = null;
            }
        }
        switch (QuickSet_operationTyte) {
            case QuickSet_operation:
                //#if NOKIA_S60V5
                 Tools.drawPopMenu(g, QuickSet_operationStr,
                         (byte) 1, Constant.FONT_SMALL.stringWidth("查看") + 2,
                         Constant.FONT_SMALL_HEIGHT + 1, 0x000000, 0xFFFFFF, 0x00CCFF, (byte) skillindex,
                         (Constant.SCREEN_WIDTH - 38 * 9) / 2 + 38 * skillQuickSetindex,
                         start_Y + (this.imgArray[1].getHeight() * 2 - 38) / 2);
                //#else
//#                Tools.drawPopMenu(g, QuickSet_operationStr,
//#                        (byte) 1, Constant.FONT_SMALL.stringWidth("查看") + 2,
//#                        Constant.FONT_SMALL_HEIGHT + 1, 0x000000, 0xFFFFFF, 0x00CCFF, (byte) skillindex,
//#                        (Constant.SCREEN_WIDTH - 25 * 9) / 2 + 25 * skillQuickSetindex,
//#                        start_Y + (this.imgArray[1].getHeight() * 2 - 25) / 2);
                //#endif
                 MainView.drawTouchRect(g, squickSetOperateRect);
                break;
            case QuickSet_view:
                if (QuickSet[skillQuickSetindex][1].equals("1")) {
                    int start_x = 9;
                    int start_y = 70;
                    if (getsetskillDescription != null) {
                        if (getsetskillDescription[0] != null) {
                            //#if NOKIA_S60V5
                             Tools.drawPopUp(g, (byte) 4, 2, start_y,
                                     Constant.SCREEN_WIDTH - 4, Constant.SCREEN_HEIGHT - start_y * 2, imgArray[9], 0x9c9c9c,
                                     null, 0, 0, 0, 0, null, 0, 0, 0, 0,
                                     getsetskillDescription[0], null);
                            //#else
//#                            Tools.drawPopUp(g, (byte) 4, 2, start_y,
//#                                    Constant.SCREEN_WIDTH - 4, Constant.SCREEN_HEIGHT - start_y * 2, imgArray[9], 0x989898,
//#                                    null, 0, 0, 0, 0, null, 0, 0, 0, 0,
//#                                    getsetskillDescription[0], null);
                            //#endif
                            Tools.drawShadowString(g, (byte) 1, "当前级别：", Constant.UI_START_X + start_x,
                                    Constant.UI_START_Y + start_y + Constant.FONT_SMALL.getHeight() + 4, 0xFFFFFF, 0x333333);
                            Tools.drawShadowString(g, (byte) 1, getsetskillDescription[1], Constant.UI_START_X + start_x + Constant.FONT_SMALL.stringWidth("当前级别："),
                                    Constant.UI_START_Y + start_y + Constant.FONT_SMALL.getHeight() + 4, 0x00E7FF, 0x333333);
                            Tools.drawShadowString(g, (byte) 1, "最高级别：", Constant.UI_START_X + start_x + Constant.SCREEN_WIDTH / 2,
                                    Constant.UI_START_Y + start_y + Constant.FONT_SMALL.getHeight() + 4, 0xFFFFFF, 0x333333);
                            Tools.drawShadowString(g, (byte) 1, getsetskillDescription[2], Constant.UI_START_X + start_x + Constant.SCREEN_WIDTH / 2 + Constant.FONT_SMALL.stringWidth("最高级别："),
                                    Constant.UI_START_Y + start_y + Constant.FONT_SMALL.getHeight() + 4, 0x00E7FF, 0x333333);
                            //
                            Tools.drawShadowString(g, (byte) 1, "精气消耗：", Constant.UI_START_X + start_x,
                                    Constant.UI_START_Y + start_y + Constant.FONT_SMALL.getHeight() * 2 + 4, 0xFFFFFF, 0x333333);
                            Tools.drawShadowString(g, (byte) 1, getsetskillDescription[4], Constant.UI_START_X + start_x + Constant.FONT_SMALL.stringWidth("精气消耗："),
                                    Constant.UI_START_Y + start_y + Constant.FONT_SMALL.getHeight() * 2 + 4, 0x00E7FF, 0x333333);
                            Tools.drawShadowString(g, (byte) 1, "CD时间：", Constant.UI_START_X + start_x + Constant.SCREEN_WIDTH / 2,
                                    Constant.UI_START_Y + start_y + Constant.FONT_SMALL.getHeight() * 2 + 4, 0xFFFFFF, 0x333333);
                            Tools.drawShadowString(g, (byte) 1, getsetskillDescription[5], Constant.UI_START_X + start_x + Constant.SCREEN_WIDTH / 2 + Constant.FONT_SMALL.stringWidth("CD时间："),
                                    Constant.UI_START_Y + start_y + Constant.FONT_SMALL.getHeight() * 2 + 4, 0x00E7FF, 0x333333);
                            //
                            Tools.drawShadowString(g, (byte) 1, "技能类别：", Constant.UI_START_X + start_x,
                                    Constant.UI_START_Y + start_y + Constant.FONT_SMALL.getHeight() * 3 + 4, 0xFFFFFF, 0x333333);
                            Tools.drawShadowString(g, (byte) 1, getsetskillDescription[3].equals("0") ? "主动" : "被动", Constant.UI_START_X + start_x + Constant.FONT_SMALL.stringWidth("技能类别："),
                                    Constant.UI_START_Y + start_y + Constant.FONT_SMALL.getHeight() * 3 + 4, 0x00E7FF, 0x333333);
                            //
                            Tools.drawHCycleRollingParagraph(g, getsetskillDescription[6],
                                    getsetskillDescription_Height, Constant.SCREEN_WIDTH - start_x * 2,
                                    Constant.SCREEN_HEIGHT - start_y * 2 - (Constant.FONT_SMALL.getHeight() * 4 + 4) - 7,
                                    Constant.FONT_SMALL.getHeight(),
                                    start_x, Constant.UI_START_Y + start_y + Constant.FONT_SMALL.getHeight() * 4 + 4,
                                    0xffffff, 0x000000);
                        }
                    }
                } else {//绘制查看物品
                }
                break;
            case QuickSet_delete:
                break;
            case QuickSet_interface:
            	MainView.drawTouchRect(g, squickSetRect);
            	break;
        }

    }
    private static int[][] squickSetRect;
    private static int[][] squickSetOperateRect;
    public void checkTouchQuickSet(int x, int y) {
    	switch (QuickSet_operationTyte) {
    	case QuickSet_interface:
    		if (squickSetRect == null) {
    			squickSetRect = new int[9][];
    			int startx = 9;
    			int starty = 181;
    			int size = 38;
    			for (int i=0;i<9;i++) {
    				squickSetRect[i] = new int[]{
    						startx+i*size,starty, size,size
    				};
    			}
    		}
    		int touched = MainCanvas.checkTouch(x, y, squickSetRect);
    		if (touched >= 0) {
    			skillQuickSetindex = touched;
    			MainCanvas.pressFire();
    		} else {
    			MainCanvas.checkSoftKey();
    		}
    		break;
        case QuickSet_operation:
//        	int size = QuickSet_operationStr.length;
//        	squickSetOperateRect = new int[size][];
//        	Tools.drawPopMenu(g, QuickSet_operationStr,
//                    (byte) 1, Constant.FONT_SMALL.stringWidth("查看") + 2,
//                    Constant.FONT_SMALL_HEIGHT + 1, 0x000000, 0xFFFFFF, 0x00CCFF, (byte) skillindex,
//                    (Constant.SCREEN_WIDTH - 38 * 9) / 2 + 38 * skillQuickSetindex,
//                    start_Y + (this.imgArray[1].getHeight() * 2 - 38) / 2);
        	int start_Y = (Constant.NEW_END_LINE - this.imgArray[1].getHeight() * 2) / 2;
        	squickSetOperateRect = Tools.getPopMenuTouch(QuickSet_operationStr,
                    (byte) 1, Constant.FONT_SMALL.stringWidth("查看") + 2,
                    Constant.FONT_SMALL_HEIGHT + 1, 0x000000, 0xFFFFFF, 0x00CCFF, (byte) skillindex,
                    (Constant.SCREEN_WIDTH - 38 * 9) / 2 + 38 * skillQuickSetindex,
                    start_Y + (this.imgArray[1].getHeight() * 2 - 38) / 2);
        	touched = MainCanvas.checkTouch(x, start_Y, squickSetOperateRect);
        	if (touched >= 0) {
        		skillindex = touched;
        		MainCanvas.pressFire();
        	} else {
        		MainCanvas.pressBack();
        	}
            break;
        case QuickSet_view:
            break;
        case QuickSet_delete:
            break;
    	}
    }
    /*
     * 清理快捷键设置
     */

    public void clearQuickSet() {
        strNote = null;
        imgArray = null;
    }
    /************************设置功能键****************************************************/
    public String[] sFunc;//功能名称
    public Image[] sFuncIcon;//功能描述
    public byte byFuncNum; //功能个数
    public byte shPos;
//public static final byte FUNC_ID_TASK = 0;//任务
//    public static final byte FUNC_ID_PROPERTY = 1;//属性
//    public static final byte FUNC_ID_EQUIP = 2;//装备
//    public static final byte FUNC_ID_PLAYER_STATUS = 3;//状态
//    public static final byte FUNC_ID_TEAM = 4;//队伍
//    public static final byte FUNC_ID_PACKAGE = 5;//背包
//    public static final byte FUNC_ID_QUALITY = 6;//画质
//    public static final byte FUNC_ID_PET = 7;//宠物
//    public static final byte FUNC_ID_SKILL = 8;//技能
//    public static final byte FUNC_ID_MERIDIAN = 9;//经脉
//    public static final byte FUNC_ID_MAP = 10;//大地图
//    public static final byte FUNC_ID_FRIEND = 11;//好友
//    public static final byte FUNC_ID_CHAT = 12;//聊天
//    public static final byte FUNC_ID_TARGET_SWITCH = 13;//目标切换
    public byte bySelectIndex;
    private byte byState;
    private boolean bKeypressLock;
    private int[] iArray;
    private int[] iFuncIConID;

    public void initFuncSetting() {
        //任务、属性、装备、状态、队伍、背包、队友切换、画质、宠物、技能、经脉、大地图、好友、聊天、目标切换
        this.sFunc = new String[]{"任务", "属性", "装备", "状态", "队伍", "背包", "画质", "宠物", "技能", "经脉", "大地图", "好友", "聊天", "目标切换", "挂机"};
        this.iFuncIConID = new int[]{1445, 1446, 1447, 1448, 1449, 1450, 1452, 1453, 1454, 1455, 1457, 1458, 1459, 1460, 1582};
        strNote = new String[]{"功能键设置", "功能："};
        byFuncNum = 15;
        shPos = 0;
        bySelectIndex = 1;
        try {
            sFuncIcon = new Image[byFuncNum];
            sFuncIcon[0] = ResManager.createImage(this.iFuncIConID[0]);
            sFuncIcon[1] = ResManager.createImage(this.iFuncIConID[1]);
            sFuncIcon[2] = ResManager.createImage(this.iFuncIConID[2]);
            sFuncIcon[3] = ResManager.createImage(this.iFuncIConID[3]);
            sFuncIcon[4] = ResManager.createImage(this.iFuncIConID[4]);
            sFuncIcon[5] = ResManager.createImage(this.iFuncIConID[5]);
            sFuncIcon[6] = ResManager.createImage(this.iFuncIConID[6]);
            sFuncIcon[7] = ResManager.createImage(this.iFuncIConID[7]);
            sFuncIcon[8] = ResManager.createImage(this.iFuncIConID[8]);
            sFuncIcon[9] = ResManager.createImage(this.iFuncIConID[9]);
            sFuncIcon[10] = ResManager.createImage(this.iFuncIConID[10]);
            sFuncIcon[11] = ResManager.createImage(this.iFuncIConID[11]);
            sFuncIcon[12] = ResManager.createImage(this.iFuncIConID[12]);
            sFuncIcon[13] = ResManager.createImage(this.iFuncIConID[13]);
            sFuncIcon[14] = ResManager.createImage(this.iFuncIConID[14]);
            //#if NOKIA_S60V5
             this.imgArray = new Image[10];
            //#else
//#            this.imgArray = new Image[6];
            //#endif
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[0] = ResManager.createImage(90000017);
//# //            imgArray[0] = Tools.ZoomImage(imgArray[0], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
            this.imgArray[0] = ResManager.createImage(90000017);//背景图片;
            //#endif
            this.imgArray[1] = Tools.makeBlueMask();//蓝色光
            this.imgArray[2] = ResManager.createImage(90000043);//文字图片
            this.imgArray[3] = ResManager.createImage(90000041);//箭头
            this.imgArray[4] = Tools.makeTransparent(29, 29, 120, 0x000000);
            this.imgArray[5] = ResManager.createImage(90000093);//选中图片
            //#if NOKIA_S60V5
             this.imgArray[6] = ResManager.createImage(90000084);//方向键
             this.imgArray[7] = ResManager.createImage(90000085);//确认件
             this.imgArray[8] = ResManager.createImage(90000086);//底部蓝条
             this.imgArray[9] = Tools.makeTransparent(ResManager.createImage(90000087), -1);//方框
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }
    }

    public void updateFuncSetting() {
        if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
            this.shPos = (byte) (this.shPos > 7 ? this.shPos - 7 : this.shPos);
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
            this.shPos = (byte) (this.shPos < 28 ? this.shPos + 7 : this.shPos);
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
            this.shPos = (byte) (this.shPos > 0 ? this.shPos - 1 : 0);
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
            this.shPos = (byte) (this.shPos < 34 ? this.shPos + 1 : 34);
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
            if (this.shPos < 15) {
                getQuickSet(String.valueOf(3), String.valueOf(this.iFuncIConID[this.shPos]), String.valueOf(this.shPos), this.sFunc[this.shPos], "", String.valueOf(0));
            }
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
            MainLogic.getInstance().pushState(Constant.GAME_UI_GAMESET_QUICKEYS, true);
        }
        MainCanvas.clearInput();
    }

    public void drawFuncSetting(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[0], this.imgArray[6], this.imgArray[7], this.imgArray[8], this.imgArray[2], this.strNote[0]);
         int startY = Constant.UI_START_Y + 110;
         int startX = Constant.UI_START_X + 12;
         Tools.drawShadowString(g, (byte) 1, this.shPos > 13 ? this.strNote[1] : this.strNote[1] + this.sFunc[this.shPos], startX, startY - 2 - Constant.FONT_SMALL_HEIGHT, 0x00ccff, 0x000000, g.LEFT | g.TOP);
         for (byte i = 0; i < 35; i++) {
             if (i % 7 == 0) {
                 startX = Constant.UI_START_X + 12;
             }
             this.drawFuncBox(g, startX, startY, i, shPos == i ? true : false);
 
             if (i % 7 == 6) {
                 startY += 48;
             }
             startX += 48;
         }
        //#else
        //#if NOKIA_S40V3 || NORMAL_240_400 || MOTO || K790
//#         Tools.setColor(g, 0x333333);
//#         g.fillRect(Constant.UI_START_X, Constant.UI_START_Y, Constant.DRAW_WIDTH, 21);
//#         g.setColor(0xCCCCCC);
//#         g.fillRect(Constant.UI_START_X, Constant.UI_START_Y + 21, Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT - 21);
//#         Tools.drawShadowString(g, (byte) 1, this.strNote[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.strNote[0])) >> 1), Constant.UI_START_Y + 1, 0xFFFFFF, 0x000000);
//#         Tools.drawSelectMask(g, (byte) 2, this.imgArray[1], Constant.UI_START_X, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 25, Constant.DRAW_WIDTH, this.imgArray[3], this.imgArray[2], 0, 0, 24, 12, this.imgArray[2], 48, 0, 24, 12);
        //#else
        //#if NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[0], this.imgArray[2], this.strNote[0]);
        //#else
//#        Tools.drawFrame(g, Constant.UI_START_X, Constant.UI_START_Y, this.imgArray[0], this.imgArray[3], this.imgArray[1], this.imgArray[2], 0, 0, 24, 12, this.imgArray[2], 48, 0, 24, 12, this.strNote[0], 0xFFFFFF);
        //#endif
        //#endif
//#        int startX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 228) >> 1);
//#        int startY = Constant.UI_START_Y + 50;
//#        Tools.drawShadowString(g, (byte) 1, this.shPos > 13 ? this.strNote[1] : this.strNote[1] + this.sFunc[this.shPos], startX, startY - 2 - Constant.FONT_SMALL_HEIGHT, 0x00ccff, 0x000000, g.LEFT | g.TOP);
//#        for (byte i = 0; i < 35; i++) {
//#            if (i % 7 == 0) {
//#                startX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 228) >> 1);
//#            }
//#            this.drawFuncBox(g, startX, startY, i, shPos == i ? true : false);
//#            if (i % 7 == 6) {
//#                startY += 33;
//#            }
//#            startX += 33;
//#        }
        //#endif
    }

    public void clearFuncSetting() {
        this.sFunc = null;
        this.sFuncIcon = null;
        this.imgArray = null;
        this.strNote = null;
        this.iFuncIConID = null;
    }

    public void drawFuncBox(Graphics g, int startX, int startY, byte index, boolean bSelected) {
        Tools.setColor(g, 0x000000);
        //#if NOKIA_S60V5
         g.drawRegion(this.imgArray[9], 0, 0, 17, 17, Constant.TRANS_NONE, startX, startY, 0);
         g.drawRegion(this.imgArray[9], 19, 0, 24, 24, Constant.TRANS_NONE, startX + 17, startY, 0);
         g.drawRegion(this.imgArray[9], 0, 0, 17, 17, Constant.TRANS_ROT180, startX + 24, startY + 24, 0);
         g.drawRegion(this.imgArray[9], 19, 0, 24, 24, Constant.TRANS_ROT180, startX, startY + 17, 0);
         startX += 6;
         startY += 6;
        //#else
//#        g.drawRect(startX, startY, 30, 30);
        //#endif
        g.drawImage(this.imgArray[4], startX + 1, startY + 1, g.LEFT | g.TOP);
        if (index < this.byFuncNum) {
            if (this.sFuncIcon[index] != null) {
                g.drawImage(this.sFuncIcon[index], startX + 1, startY + 1, g.LEFT | g.TOP);
            }
        }
        if (bSelected) {
            //#if NOKIA_S60V5
             Goods.drawGoodsSelectStytle(g, this.imgArray[5], startX - 6, startY - 6);
            //#else
//#            Goods.drawGoodsSelectStytle(g, this.imgArray[5], startX, startY);
            //#endif
        }
    }

    /**
     * 运行功能
     * @param byFuncID 
     */
    public static void runFunc(byte byFuncID) {
        switch (byFuncID) {
            case Constant.FUNC_ID_TASK://任务
                GameBean.BY_PRE_GAME_UI_STATE = -1;
                MainLogic.getInstance().byQuickToRoam = true;
                MainLogic.getInstance().uiInterFace.npcTalk.openTaskList();
                break;
            case Constant.FUNC_ID_PROPERTY://属性
                MainLogic.getInstance().byQuickToRoam = true;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_CHECK_PROPERTY, Constant.SOCKET_MSG_TYPE_LOGIC);
                break;
            case Constant.FUNC_ID_EQUIP://装备
                MainLogic.getInstance().byQuickToRoam = true;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_EQUIP, Constant.SOCKET_MSG_TYPE_LOGIC);
                break;
            case Constant.FUNC_ID_PLAYER_STATUS://状态
                MainLogic.getInstance().byQuickToRoam = true;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_CHECK_MEFFECT, Constant.SOCKET_MSG_TYPE_LOGIC);
                break;
            case Constant.FUNC_ID_TEAM://队伍
                if (MainLogic.getInstance().uiInterFace.team.getTeamMemberNum() > 0) {
                    MainLogic.getInstance().byQuickToRoam = true;
                    MainLogic.getInstance().pushState(Constant.GAME_UI_TEAM_INFO, true);
                } else {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您还没有加入任何队伍!");
                }
                break;
            case Constant.FUNC_ID_PACKAGE://背包
                MainLogic.getInstance().byQuickToRoam = true;
                MainLogic.getInstance().uiPackage.openBag(Constant.ITEM_COLUMN_TYPE_COMMON);
                break;
            case Constant.FUNC_ID_QUALITY://画质
                MainLogic.uiEquipment.flow = (byte) (MainLogic.uiEquipment.flow + 1 > 2 ? 0 : MainLogic.uiEquipment.flow + 1);
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_SET_FLOW, Constant.SOCKET_MSG_TYPE_LOGIC);
                switch (MainLogic.uiEquipment.flow) {
                    case 0:
                        MainLogic.getInstance().uiEquipment.getChatInformation(100, "", (byte) 5, "您的流量已经设置为高状态");
                        break;
                    case 1:
                        MainLogic.getInstance().uiEquipment.getChatInformation(100, "", (byte) 5, "您的流量已经设置为中状态");
                        break;
                    case 2:
                        MainLogic.getInstance().uiEquipment.getChatInformation(100, "", (byte) 5, "您的流量已经设置为低状态");
                        break;
                }
                break;
            case Constant.FUNC_ID_PET://宠物
                MainLogic.getInstance().byQuickToRoam = true;
                GameBean.L_PLAYER_ID = MainLogic.getInstance().gamePlayer.lPlayerID;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_PET, Constant.SOCKET_MSG_TYPE_LOGIC);
                break;
            case Constant.FUNC_ID_SKILL://技能
                MainLogic.getInstance().byQuickToRoam = true;
                MainLogic.getInstance().send(Constant.MSG_NET_OPEN_KUNGFU, Constant.SOCKET_MSG_TYPE_LOGIC);
                break;
            case Constant.FUNC_ID_MERIDIAN://经脉
                MainLogic.getInstance().byQuickToRoam = true;
                MainLogic.getInstance().uiEquipment.meridianschoose_index = 0;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_MERIDIAN, Constant.SOCKET_MSG_TYPE_LOGIC);
                break;
            case Constant.FUNC_ID_MAP://大地图
                MainLogic.getInstance().byQuickToRoam = true;
                MainLogic.getInstance().pushState(Constant.GAME_UI_MAP_WORLD, true);
                break;
            case Constant.FUNC_ID_FRIEND://好友
                MainLogic.getInstance().byQuickToRoam = true;
                GameBean.BY_CMD_FRIEND_TYPE = 1;
                GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_ROAM_MENU;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_FRIEND_LIST, Constant.SOCKET_MSG_TYPE_LOGIC);
                GameBean.b_WAIT_NET_MSG_BACK = true;
                break;
            case Constant.FUNC_ID_CHAT://聊天
                MainLogic.getInstance().byQuickToRoam = true;
                MainLogic.getInstance().pushState(Constant.GAME_UI_CHAT, true);
                break;
            case Constant.FUNC_ID_TARGET_SWITCH://目标切换
                SkillBuffManager.clearBuffTable();
                if (MainLogic.getInstance().iLockedObjNumber[0][0] != -1) {
                    MainLogic.getInstance().LockedObj_index++;
                    MainLogic.getInstance().lockedObj(MainLogic.getInstance().gamePlayer.iPlayerX, MainLogic.getInstance().gamePlayer.iPlayerY);
                } else {
                    MainLogic.getInstance().LockedObj_index = 0;
                    MainLogic.getInstance().lockedObj(MainLogic.getInstance().gamePlayer.iPlayerX, MainLogic.getInstance().gamePlayer.iPlayerY);
                }
                break;
            case Constant.FUNC_ID_HANG_UP://快捷键挂机
//                GameBean.BL_PLAYER_HANGUP = GameBean.BL_PLAYER_HANGUP ? false : true;
                MainLogic.getInstance().clearLockedObj(0, true);
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_ONLINEHANG, Constant.SOCKET_MSG_TYPE_LOGIC);
                break;
            default:
                break;
        }
    }

    /**
     * 通过功能的ID获得功能的名称
     * @param byFuncID
     * @return 
     */
    public static String getFuncName(byte byFuncID) {
        if (byFuncID >= 0) {
            String[] sFuncTemp = new String[]{"任务", "属性", "装备", "状态", "队伍", "背包", "画质", "宠物", "技能", "经脉", "大地图", "好友", "聊天", "目标切换", "挂机"};
            return sFuncTemp[byFuncID];
        } else {
            return "";
        }
    }

    /**
     * 通过功能的ID获得功能的icon id
     * @param byFuncID
     * @return 
     */
    public static String getFuncIconID(byte byFuncID) {
        int[] iFuncIConID = new int[]{1445, 1446, 1447, 1448, 1449, 1450, 1452, 1453, 1454, 1455, 1457, 1458, 1459, 1460, 1582};
        return String.valueOf(iFuncIConID[byFuncID]);
    }
    /**************玩家充值********************************************************/
    public String[] sArray;
    public int startX;
    public int startY;
    public byte byChargeType;//充值的类型(1,神州付,2,易宝，3当乐)
    public byte byChargeCardType;//充值卡的类型
    public byte byChareCardMoney;//充值卡的金额
    public String[] sChargeDesc;//充值的描述
    public int[] iChargeDescHeight;//充值描述的高度
    public int totalHeight;
    public int iStartOffSet;
    public int descHeight;

    public void initCharge() {
//        openCharge();
        try {
            //#if NOKIA_S60V5
             this.iPositionY = Constant.UI_START_X + 50;
             this.iUiHeight = Constant.END_LINE - 70;
             this.imgArray = new Image[10];
            //#else
//#            this.iPositionY = Constant.UI_START_X + 30;
//#            this.iUiHeight = Constant.DRAW_HEIGHT - 70;
//#            this.imgArray = new Image[6];
            //#endif
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[0] = ResManager.createImage(90000017);
//# //            imgArray[0] = Tools.ZoomImage(imgArray[0], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
            this.imgArray[0] = ResManager.createImage(90000017);//背景图片;
            //#endif
            this.imgArray[1] = Tools.makeBlueMask();//蓝色光
            this.imgArray[2] = ResManager.createImage(90000043);//文字图片
            this.imgArray[3] = ResManager.createImage(90000041);//箭头
            this.imgArray[4] = Tools.makeTransparent(29, 29, 120, 0x000000);
            this.imgArray[5] = ResManager.createImage(90000093);//选中图片
            //#if NOKIA_S60V5
             this.imgArray[6] = ResManager.createImage(90000084);//方向键
             this.imgArray[7] = ResManager.createImage(90000085);//确认件
             this.imgArray[8] = ResManager.createImage(90000086);//底部蓝条
             this.imgArray[9] = Tools.makeTransparent(ResManager.createImage(90000087), -1);//方框
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }
        this.iStartOffSet = 0;
        descHeight = Tools.getParagraphHeight(strNote[1], Constant.DRAW_WIDTH - 30, Constant.FONT_SMALL_HEIGHT + 1);
    }

    public void updateCharge() {
        switch (this.byState) {
            case 0://充值类型选择
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                    this.bySelectIndex = (byte) (this.bySelectIndex == 1 ? 2 : 1);
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                    this.byState = 1;
                    this.byChargeType = this.bySelectIndex;
                    this.sArray = this.getChargeCardType(this.byChargeType);
                    this.strNote[0] = this.getChargeTitle(byState, this.byChargeType, this.byChargeCardType);
                    this.bySelectIndex = 1;
                    this.totalHeight = this.sArray.length * (Constant.FONT_SMALL_HEIGHT + 5);
                    this.iStartOffSet = 0;
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                    MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM_MENU, true);//返回漫游界面
                    MainLogic.getInstance().uiInterFace.setMenu((byte) 1, (byte) 1, 3);
                }
                break;
            case 1://充值卡类型选择(移动，联通，电信，骏网)
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                    this.bySelectIndex = (byte) (this.bySelectIndex == 1 ? this.sArray.length : this.bySelectIndex - 1);
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                    this.bySelectIndex = (byte) (this.bySelectIndex == this.sArray.length ? 1 : this.bySelectIndex + 1);
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                    this.byState = 2;
                    this.byChargeCardType = this.bySelectIndex;
                    this.sArray = this.getChargeCardMoney(this.byChargeCardType);
                    this.strNote[0] = this.getChargeTitle(byState, this.byChargeType, this.byChargeCardType);
                    this.bySelectIndex = 1;
                    this.totalHeight = (Constant.FONT_SMALL_HEIGHT + 5) * this.sArray.length;
                    this.iStartOffSet = 0;
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                    if (this.byChargeType == 3 || Constant.CHANNEL_NUM.equals("10010001")) {
                        MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM_MENU, true);//返回漫游界面
                        MainLogic.getInstance().uiInterFace.setMenu((byte) 1, (byte) 1, 3);
                    } else {
                        this.byState = 0;
                        this.strNote[0] = this.getChargeTitle(byState, this.byChargeType, this.byChargeCardType);
                        this.sArray = this.getChargeType();
                        this.bySelectIndex = this.byChargeType;
                        this.totalHeight = this.sArray.length * (Constant.FONT_SMALL_HEIGHT + 5);
                        this.iStartOffSet = 0;
                    }
                }
                break;
            case 2://充值卡金额选择
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                    this.iStartOffSet = 0;
                    this.bySelectIndex = (byte) (this.bySelectIndex == 1 ? this.sArray.length : this.bySelectIndex - 1);
                    if (this.totalHeight > this.iUiHeight - descHeight) {
                        if (this.bySelectIndex * (Constant.FONT_SMALL_HEIGHT + 5) > this.iUiHeight - descHeight) {
                            this.iStartOffSet = this.bySelectIndex * (Constant.FONT_SMALL_HEIGHT + 5) - (this.iUiHeight - descHeight - 10);
                        }
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                    this.iStartOffSet = 0;
                    this.bySelectIndex = (byte) (this.bySelectIndex == this.sArray.length ? 1 : this.bySelectIndex + 1);
                    if (this.totalHeight > this.iUiHeight - descHeight) {
                        if (this.bySelectIndex * (Constant.FONT_SMALL_HEIGHT + 5) > this.iUiHeight - descHeight) {
                            this.iStartOffSet = this.bySelectIndex * (Constant.FONT_SMALL_HEIGHT + 5) - (this.iUiHeight - descHeight - 10);
                        }
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                    if (this.bySelectIndex == this.sArray.length) {
                        this.byState = 3;
                        this.strNote[0] = "充值说明";
                        this.getChargeDesc(byChargeCardType);
                        this.iStartOffSet = 0;
                    } else {
                        //跳转到高级界面
                        this.byChareCardMoney = this.bySelectIndex;
                        MainLogic.getInstance().inputInterFace.setInputInterFace(this.byState, "充值");
                        MainGame.changeCanvas(MainLogic.getInstance().inputInterFace);
                    }
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                    this.byState = 1;
                    this.bySelectIndex = 1;
                    this.strNote[0] = this.getChargeTitle(byState, this.byChargeType, this.byChargeCardType);
                    this.sArray = this.getChargeCardType(this.byChargeType);
                    this.bySelectIndex = this.byChargeCardType;
                    this.totalHeight = this.sArray.length * (Constant.FONT_SMALL_HEIGHT + 5);
                    this.iStartOffSet = 0;
                }
                break;
            case 3:
                if ((MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false))) {
                    if (this.totalHeight > this.iUiHeight) {
                        this.iStartOffSet = this.iStartOffSet > 0 ? this.iStartOffSet - Constant.FONT_SMALL_HEIGHT * 3 : 0;
                        this.iStartOffSet = this.iStartOffSet >= 0 ? this.iStartOffSet : 0;
                    }
                } else if ((MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false))) {
                    if (this.totalHeight > this.iUiHeight) {
                        this.iStartOffSet = this.iStartOffSet + Constant.FONT_SMALL_HEIGHT * 3 + this.iUiHeight >= this.totalHeight ? this.totalHeight - this.iUiHeight : this.iStartOffSet + Constant.FONT_SMALL_HEIGHT * 3;
                    }
                } else if ((MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false))) {
                    this.byState = 2;
                    this.strNote[0] = this.getChargeTitle(byState, this.byChargeType, this.byChargeCardType);
                    this.totalHeight = this.sArray.length * (Constant.FONT_SMALL_HEIGHT + 5);
                    if (this.totalHeight > this.iUiHeight - descHeight) {
                        if (this.bySelectIndex * (Constant.FONT_SMALL_HEIGHT + 5) > this.iUiHeight - descHeight) {
                            this.iStartOffSet = this.bySelectIndex * (Constant.FONT_SMALL_HEIGHT + 5) - (this.iUiHeight - descHeight - 10);
                        }
                    } else {
                        this.iStartOffSet = 0;
                    }
                }
                break;
        }
        MainCanvas.clearInput();
    }

    public void drawCharge(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[0], this.imgArray[6], this.imgArray[7], this.imgArray[8], this.imgArray[2], this.strNote[0]);
        //#else
        //#if NOKIA_S40V3 || NORMAL_240_400 || MOTO || K790
//#         Tools.setColor(g, 0x333333);
//#         g.fillRect(Constant.UI_START_X, Constant.UI_START_Y, Constant.DRAW_WIDTH, 21);
//#         g.setColor(0xCCCCCC);
//#         g.fillRect(Constant.UI_START_X, Constant.UI_START_Y + 21, Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT - 21);
//#         Tools.drawShadowString(g, (byte) 1, this.strNote[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.strNote[0])) >> 1), Constant.UI_START_Y + 1, 0xFFFFFF, 0x000000);
//#         Tools.drawSelectMask(g, (byte) 2, this.imgArray[1], Constant.UI_START_X, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 25, Constant.DRAW_WIDTH, this.imgArray[3], this.imgArray[2], 0, 0, 24, 12, this.imgArray[2], 48, 0, 24, 12);
        //#else
        //#if NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[0], this.imgArray[2], this.strNote[0]);
        //#else
//#        Tools.drawFrame(g, Constant.UI_START_X, Constant.UI_START_Y, this.imgArray[0], this.imgArray[3], this.imgArray[1], this.imgArray[2], 0, 0, 24, 12, this.imgArray[2], 48, 0, 24, 12, this.strNote[0], 0xFFFFFF);
        //#endif
        //#endif
        //#endif
        //绘制充值提示
        startX = Constant.UI_START_X + 15;
        switch (this.byState) {
            case 0:
            case 1:
            case 2:
                Tools.drawParagraph(g, startX, this.iPositionY, Constant.DRAW_WIDTH - 30, strNote[1], 0xFFFFFF, Constant.FONT_SMALL_HEIGHT + 1, 0x000000);
                startY = this.iPositionY + descHeight;//描述警告
                if (totalHeight <= this.iUiHeight - descHeight) {
                    startY += (this.iUiHeight - descHeight - totalHeight >> 1);
                    for (byte i = 0; i < this.sArray.length; i++) {
                        Tools.drawShadowString(g, (byte) 1, this.sArray[i], startX, startY + (Constant.FONT_SMALL_HEIGHT + 5) * i, this.bySelectIndex == i + 1 ? Constant.SELECTED_COLOR : 0xFFFFFF, 0x000000);
                    }
                    
                    Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, startY + this.bySelectIndex * (Constant.FONT_SMALL_HEIGHT + 5) - 3, Constant.DRAW_WIDTH);
                } else {
                    startY += 10;
                    g.setClip(Constant.UI_START_X, this.startY, Constant.DRAW_WIDTH, this.iUiHeight - descHeight - 10);
                    startY -= this.iStartOffSet;
                    for (byte i = 0; i < this.sArray.length; i++) {
                        Tools.drawShadowString(g, (byte) 1, this.sArray[i], startX, startY + (Constant.FONT_SMALL_HEIGHT + 5) * i, this.bySelectIndex == i + 1 ? Constant.SELECTED_COLOR : 0xFFFFFF, 0x000000);
                    }
                    Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, startY + this.bySelectIndex * (Constant.FONT_SMALL_HEIGHT + 5) - 3, Constant.DRAW_WIDTH);
                    g.setClip(Constant.UI_START_X, Constant.UI_START_Y, Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
                }
                break;

            case 3:
                startY = this.iPositionY;
                g.setClip(Constant.UI_START_X, startY, Constant.DRAW_WIDTH, this.iUiHeight);
                startY -= this.iStartOffSet;
                for (byte i = 0; i < this.sChargeDesc.length; i++) {
                    //首先绘制数字
                    g.setColor(0xFFFFFF);
                    g.drawString(String.valueOf(i + 1) + this.strNote[2], Constant.UI_START_X + 10, startY, 0);
                    Tools.drawParagraph(g, Constant.UI_START_X + 25, startY, Constant.DRAW_WIDTH - 35, this.sChargeDesc[i], 0xFFFFFF, Constant.FONT_SMALL_HEIGHT + 1, 0x000000);
                    this.startY += this.iChargeDescHeight[i];
                }
                g.setClip(Constant.UI_START_X, Constant.UI_START_Y, Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
                break;
        }
    }

    public void clearCharge() {
        this.imgArray = null;
        this.sArray = null;
        this.strNote = null;
    }

    public String[] getChargeType() {
        return new String[]{"神州付充值", "易宝支付充值"};
    }

    private String getChargeTitle(byte byState, byte byChargeType, byte byChargeCardType) {
        switch (this.byState) {
            case 0:
                return "充值";
            case 1:
                switch (byChargeType) {
                    case 1:
                        return "神州付支付充值";
                    case 2:
                        return Constant.CHANNEL_NUM.equals("10010001") ? "九游支付充值" : "易宝支付充值";
                    case 3:
                        return "当乐支付充值";
                }
                break;
            case 2:
                switch (byChargeCardType) {
                    case 1:
                        return "移动充值卡";
                    case 2:
                        return "联通充值卡";
                    case 3:
                        return "电信充值卡";
                    case 4:
                        return "骏网一卡通";
                }
        }
        return "";
    }

    /**
     * 不同的充值类型的可以选择的卡的类型
     * @param byCharge
     * @return 
     */
    private String[] getChargeCardType(byte byCharge) {
        switch (byCharge) {
            case 1://神州付 
                return new String[]{"移动充值卡", "联通充值卡", "电信充值卡"};
            case 2://易宝支付
                return new String[]{"移动充值卡", "联通充值卡", "电信充值卡", "骏网一卡通"};
            case 3://当乐支付
                return new String[]{"移动充值卡", "联通充值卡", "电信充值卡", "骏网一卡通"};
        }
        return null;
    }

    /**移动充值卡开通面额：
     */
    public String[] getChargeCardMoney(byte byCardType) {
        switch (byCardType) {
            case 1://移动充值卡
                return new String[]{"移动充值卡10元卡", "移动充值卡20元卡", "移动充值卡30元卡", "移动充值卡50元卡", "移动充值卡100元卡", "移动充值卡300元卡", "移动充值卡500元卡", "充值说明"};
            case 2://联通充值卡
                return new String[]{"联通充值卡20元卡", "联通充值卡30元卡", "联通充值卡50元卡", "联通充值卡100元卡", "联通充值卡300元卡", "联通充值卡500元卡", "充值说明"};
            case 3://电信充值卡
                return new String[]{"电信充值卡20元卡", "电信充值卡30元卡", "电信充值卡50元卡", "电信充值卡100元卡", "充值说明"};
            case 4://骏网一卡通
                return new String[]{"骏网一卡通1元卡", "骏网一卡通5元卡", "骏网一卡通10元卡", "骏网一卡通15元卡", "骏网一卡通30元卡", "骏网一卡通50元卡", "骏网一卡通100元卡", "充值说明"};
        }
        return null;
    }

    public void getChargeDesc(byte byChargeCardType) {
        this.totalHeight = 0;
        this.iStartOffSet = 0;
        switch (byChargeCardType) {
            case 1://移动充值卡
                this.sChargeDesc = new String[8];
                this.iChargeDescHeight = new int[8];
                this.sChargeDesc[0] = "支持使用序列号17位，密码18位阿拉伯数字中国移动发行的能够充值手机话费的中国移动充值付费卡；";
                this.sChargeDesc[1] = "目前支持10元、20元、30元、50元、100元、300元和500元面额的移动充值卡；";
                this.sChargeDesc[2] = "同时支持【浙江：卡号10位，密码8位】【福建：卡号16位，密码17位】【广东：卡号17位，密码18位】【辽宁：卡号16位，密码21位】【辽宁：卡号16位，密码17位】五省地方移动充值卡，其他暂不支持；";
                this.sChargeDesc[3] = "卡内金额将一次全额扣除，请务必使用与此面额相同的移动充值卡，否则会导致支付不成功，或是支付金额丢失，我们无法帮您找回;";
                this.sChargeDesc[4] = "请仔细核对您的充值卡序列号和密码，如果因为输入错误导致您的充值卡失效，我们无法为您提供补救服务；";
                this.sChargeDesc[5] = "请注意，系统不支持任何面额的彩铃充值卡和短信充值卡，请务必不要使用相关卡片充值，以免给您带来损失；";
                this.sChargeDesc[6] = "由于网络情况，您的充值可能有些许延迟，一般在1-30分钟兑换完成，超过30分钟，请您拨打客服电话；";
                this.sChargeDesc[7] = "客服电话:400-663-6338";
                for (byte i = 0; i < 8; i++) {
                    this.iChargeDescHeight[i] = Tools.getParagraphHeight(this.sChargeDesc[i], Constant.DRAW_WIDTH - 35, Constant.FONT_SMALL_HEIGHT + 1);
                    this.totalHeight += this.iChargeDescHeight[i];
                }
                break;
            case 2://联通充值卡
                this.sChargeDesc = new String[7];
                this.iChargeDescHeight = new int[7];
                this.sChargeDesc[0] = "支持使用序列号15位，密码19位阿拉伯数字中国联通发行的能够充值手机话费的中国联通充值付费卡；";
                this.sChargeDesc[1] = "目前支持20元、30元、50元、100元，300元和500元面额的联通充值卡；";
                this.sChargeDesc[2] = "卡内金额将一次全额扣除，请务必使用与此面额相同的充值卡，否则会导致支付不成功，或是支付金额丢失，我们无法帮您找回;";
                this.sChargeDesc[3] = "请仔细核对您的充值卡序列号和密码，如果因为输入错误导致您的充值卡失效，我们无法为您提供补救服务；";
                this.sChargeDesc[4] = "请注意，系统不支持任何面额的彩铃充值卡和短信充值卡，请务必不要使用相关卡片充值，以免给您带来损失；";
                this.sChargeDesc[5] = "由于网络情况，您的充值可能有些许延迟，一般在1-30分钟兑换完成，超过30分钟，请您拨打客服电话；";
                this.sChargeDesc[6] = "客服电话:400-663-6338";
                for (byte i = 0; i < 7; i++) {
                    this.iChargeDescHeight[i] = Tools.getParagraphHeight(this.sChargeDesc[i], Constant.DRAW_WIDTH - 35, Constant.FONT_SMALL_HEIGHT + 1);
                    this.totalHeight += this.iChargeDescHeight[i];
                }
                break;
            case 3://电信充值卡
                this.sChargeDesc = new String[7];
                this.iChargeDescHeight = new int[7];
                this.sChargeDesc[0] = "支持使用序列号19位，密码18位阿拉伯数字中国电信发行的能够充值手机话费的中国电信充值付费卡；";
                this.sChargeDesc[1] = "目前支持20元、30元、50元和100元面额的电信充值卡；";
                this.sChargeDesc[2] = "卡内金额将一次全额扣除，请务必使用与此面额相同的电信充值卡，否则会导致支付不成功，或是支付金额丢失，我们无法帮您找回;";
                this.sChargeDesc[3] = "请仔细核对您的充值卡序列号和密码，如果因为输入错误导致您的充值卡失效，我们无法为您提供补救服务；";
                this.sChargeDesc[4] = "请注意，仅支持中国电信发行的，能过充值手机话费的中国电信付费卡，请不要使用任何新的业务充值卡，以免给您带来损失；";
                this.sChargeDesc[5] = "由于网络情况，您的充值可能有些许延迟，一般在1-30分钟兑换完成，超过30分钟，请您拨打客服电话；";
                this.sChargeDesc[6] = "客服电话:400-663-6338";
                for (byte i = 0; i < 7; i++) {
                    this.iChargeDescHeight[i] = Tools.getParagraphHeight(this.sChargeDesc[i], Constant.DRAW_WIDTH - 35, Constant.FONT_SMALL_HEIGHT + 1);
                    this.totalHeight += this.iChargeDescHeight[i];
                }
                break;
            case 4://骏网一卡通
                this.sChargeDesc = new String[7];
                this.iChargeDescHeight = new int[7];
                this.sChargeDesc[0] = "支持使用序列号16位，密码16位阿拉伯数字骏网充值卡充值；";
                this.sChargeDesc[1] = "目前支持1元、5元、10元、15元、30元、50元和100元面额的骏网充值卡；";
                this.sChargeDesc[2] = "卡内金额将一次全额扣除，请务必使用与此面额相同的充值卡，否则会导致支付不成功，或是支付金额丢失，我们无法帮您找回;";
                this.sChargeDesc[3] = "不能使用特定的专属支付卡支付，特定游戏包括大唐双风云、传说、蜗牛、猫扑一卡通、九鼎、雅典娜、山河等游戏；";
                this.sChargeDesc[4] = "请仔细核对您的充值卡序列号和密码，如果因为输入错误导致您的充值卡失效，我们无法为您提供补救服务；";
                this.sChargeDesc[5] = "由于网络情况，您的充值可能有些许延迟，一般在1-30分钟兑换完成，超过30分钟，请您拨打客服电话；";
                this.sChargeDesc[6] = "客服电话:400-663-6338";
                for (byte i = 0; i < 7; i++) {
                    this.iChargeDescHeight[i] = Tools.getParagraphHeight(this.sChargeDesc[i], Constant.DRAW_WIDTH - 35, Constant.FONT_SMALL_HEIGHT + 1);
                    this.totalHeight += this.iChargeDescHeight[i];
                }
                break;
        }
    }

    /**
     * 打开充值界面
     */
    public void openCharge() {
        strNote = new String[]{"", "注意：请选中正确的金额，选择的金额与卡面额不符，可能会造成充值卡失效，无法找回!", " . "};
        if (Constant.CHANNEL_NUM.equals("10000001")) {//当了充值
            this.byState = 1;
            this.byChargeType = 3;
            this.byChargeCardType = -1;
            this.sArray = this.getChargeCardType(this.byChargeType);
            this.strNote[0] = this.getChargeTitle(byState, this.byChargeType, this.byChargeCardType);
            this.bySelectIndex = 1;
        } else if (Constant.CHANNEL_NUM.equals("10010001")) {//久游
            this.byState = 1;
            this.byChargeType = 2;
            this.byChargeCardType = -1;
            this.sArray = this.getChargeCardType(this.byChargeType);
            this.strNote[0] = this.getChargeTitle(byState, this.byChargeType, this.byChargeCardType);
            this.bySelectIndex = 1;
        } else {
            this.byState = 0;
            this.byChargeType = -1;
            this.byChargeCardType = -1;
            this.strNote[0] = this.getChargeTitle(byState, this.byChargeType, this.byChargeCardType);
            this.sArray = this.getChargeType();
            this.bySelectIndex = 1;
        }
        totalHeight = this.sArray.length * (Constant.FONT_SMALL_HEIGHT + 5);
        MainLogic.getInstance().pushState(Constant.GAME_UI_CHARGE, true);
    }

    public short getCardMoney() {
        short[] moneyArray;
        short money = 0;
        switch (this.byChargeCardType) {
            case 1:
                moneyArray = new short[]{10, 20, 30, 50, 100, 300, 500};
                money = moneyArray[this.byChareCardMoney - 1];
                break;
            case 2:
                moneyArray = new short[]{20, 30, 50, 100, 300, 500};
                money = moneyArray[this.byChareCardMoney - 1];
                break;
            case 3:
                moneyArray = new short[]{20, 30, 50, 100};
                money = moneyArray[this.byChareCardMoney - 1];
                break;
            case 4:
                moneyArray = new short[]{1, 5, 10, 15, 30, 50, 100};
                money = moneyArray[this.byChareCardMoney - 1];
                break;
        }
        return money;
    }

    public byte getCardRealType() {
        byte byRealType = -1;
        switch (this.byChargeType) {
            case 1://神州付充值
                switch (this.byChargeCardType) {
                    case 1://移动
                        byRealType = 0;
                        break;
                    case 2://联通
                        byRealType = 1;
                        break;
                    case 3://电信
                        byRealType = 2;
                        break;
                }
                break;
            case 2://易宝
                switch (this.byChargeCardType) {
                    case 1://移动
                        byRealType = 2;
                        break;
                    case 2://联通
                        byRealType = 5;
                        break;
                    case 3://电信
                        byRealType = 11;
                        break;
                    case 4://骏网
                        byRealType = 0;
                        break;
                }
                break;
            case 3://当了
                switch (this.byChargeCardType) {
                    case 1://移动
                        byRealType = 6;
                        break;
                    case 2://联通
                        byRealType = 7;
                        break;
                    case 3://电信
                        byRealType = 16;
                        break;
                    case 4://骏网
                        byRealType = 10;
                        break;
                }
                break;
        }
        return byRealType;
    }

    public void openChargeList(String[] list) {
//        list = new String[]{"没有找到充值记录没有找到没有找到充值记录没有找到充值记录充值记录", "没有找没有找到充值记录没有找到充值记录到充值记录", "没有找没有找到充值记录没有找到充值记录到充值记录", "没有找到没有找到充值记录没有找到充值记录充值记录", "没有找到充值记录", "没有找到没有找到充值记录没有找到充值记录没有找到充值记录充值记录", "没有找到没有找到充值记录没有找到充值记录充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录", "没有找到充值记录"};
        this.sChargeDesc = list;
        if (this.sChargeDesc == null) {
            this.sChargeDesc = new String[]{"没有找到充值记录"};
        }
        this.iChargeDescHeight = new int[this.sChargeDesc.length];
        for (byte i = 0; i < this.sChargeDesc.length; i++) {
            this.iChargeDescHeight[i] = Tools.getParagraphHeight(this.sChargeDesc[i], Constant.DRAW_WIDTH - 30, Constant.FONT_SMALL_HEIGHT + 1);
            this.totalHeight += this.iChargeDescHeight[i];
        }
        MainLogic.getInstance().pushState(Constant.GAME_UI_CHARGE_LIST, true);

    }

    public void initChargeList() {
//        openChargeList(null);
        this.strNote = new String[]{"充值明细"};
        this.iStartOffSet = 0;
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[10];
             this.iPositionY = Constant.UI_START_Y + 50;
             this.iUiHeight = Constant.END_LINE - 70;
            //#else
//#            this.iPositionY = Constant.UI_START_Y + 30;
//#            this.iUiHeight = Constant.DRAW_HEIGHT - 70;
//#            this.imgArray = new Image[6];
            //#endif
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[0] = ResManager.createImage(90000017);
//# //            imgArray[0] = Tools.ZoomImage(imgArray[0], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
            this.imgArray[0] = ResManager.createImage(90000017);//背景图片;
            //#endif
            this.imgArray[1] = Tools.makeBlueMask();//蓝色光
            this.imgArray[2] = ResManager.createImage(90000043);//文字图片
            this.imgArray[3] = ResManager.createImage(90000041);//箭头
            this.imgArray[4] = Tools.makeTransparent(29, 29, 120, 0x000000);
            this.imgArray[5] = ResManager.createImage(90000093);//选中图片
            //#if NOKIA_S60V5
             this.imgArray[6] = ResManager.createImage(90000084);//方向键
             this.imgArray[7] = ResManager.createImage(90000085);//确认件
             this.imgArray[8] = ResManager.createImage(90000086);//底部蓝条
             this.imgArray[9] = Tools.makeTransparent(ResManager.createImage(90000087), -1);//方框
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }
    }

    public void updateChargeList() {
        if ((MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false))) {
            if (this.totalHeight > this.iUiHeight) {
                this.iStartOffSet = this.iStartOffSet > 0 ? this.iStartOffSet - Constant.FONT_SMALL_HEIGHT * 3 : 0;
                this.iStartOffSet = this.iStartOffSet >= 0 ? this.iStartOffSet : 0;
            }
        } else if ((MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false))) {
            if (this.totalHeight > this.iUiHeight) {
                this.iStartOffSet = this.iStartOffSet + Constant.FONT_SMALL_HEIGHT * 3 + this.iUiHeight >= this.totalHeight ? this.totalHeight - this.iUiHeight : this.iStartOffSet + Constant.FONT_SMALL_HEIGHT * 3;
            }
        } else if ((MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false))) {
            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM_MENU, true);
            MainLogic.getInstance().uiInterFace.setMenu((byte) 1, (byte) 1, 3);
        }
    }

    public void drawChargeList(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[0], this.imgArray[6], this.imgArray[7], this.imgArray[8], this.imgArray[2], this.strNote[0]);
        //#else
        //#if NOKIA_S40V3 || NORMAL_240_400 || MOTO || K790
//#         Tools.setColor(g, 0x333333);
//#         g.fillRect(Constant.UI_START_X, Constant.UI_START_Y, Constant.DRAW_WIDTH, 21);
//#         g.setColor(0xCCCCCC);
//#         g.fillRect(Constant.UI_START_X, Constant.UI_START_Y + 21, Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT - 21);
//#         Tools.drawShadowString(g, (byte) 1, this.strNote[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.strNote[0])) >> 1), Constant.UI_START_Y + 1, 0xFFFFFF, 0x000000);
//#         Tools.drawSelectMask(g, (byte) 2, this.imgArray[1], Constant.UI_START_X, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 25, Constant.DRAW_WIDTH, this.imgArray[3], this.imgArray[2], 0, 0, 24, 12, this.imgArray[2], 48, 0, 24, 12);
        //#else
        //#if NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[0], this.imgArray[2], this.strNote[0]);
        //#else
//#        Tools.drawFrame(g, Constant.UI_START_X, Constant.UI_START_Y, this.imgArray[0], this.imgArray[3], this.imgArray[1], this.imgArray[2], 0, 0, 24, 12, this.imgArray[2], 48, 0, 24, 12, this.strNote[0], 0xFFFFFF);
        //#endif
        //#endif
        //#endif
        //绘制充值提示
        g.setClip(Constant.UI_START_X, this.iPositionY, Constant.DRAW_WIDTH, iUiHeight);
        startY = this.iPositionY;
        startY -= this.iStartOffSet;
        startX = Constant.UI_START_X + 15;
        for (byte i = 0; i < this.sChargeDesc.length; i++) {
            Tools.drawParagraph(g, Constant.UI_START_X + 15, startY, Constant.DRAW_WIDTH - 30, this.sChargeDesc[i], 0xFFFFFF, Constant.FONT_SMALL_HEIGHT + 1, 0x000000);
            this.startY += this.iChargeDescHeight[i];
        }
        g.setClip(Constant.UI_START_X, Constant.UI_START_Y, Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
    }

    public void clearChargeList() {
        this.sChargeDesc = null;
        this.imgArray = null;
        this.iChargeDescHeight = null;
        this.strNote = null;
    }
}
